<?php
include('../config.php');

$username = $_GET['username'];
$password = $_GET['password'];

$sql = "select * from tb_user where username='$username' and password='$password'";

// $res是一个资源类型
$res = mysql_query($sql);

$list = array();
// 通过循环去资源里抓取数据，每取一行，都是一个$row，取完了循环也就结束了
while ($row = mysql_fetch_assoc($res)) {
  array_push($list, $row);
}

if (mysql_num_rows($res) > 0) {
    echo json_encode(array(
      "code" => 200,
      "body" => array(
        "list" => $list
      )
    ));
  } else {
    echo json_encode(array(
      "code" => 201,
      "body" => array(
        "msg" => "网络错误，别试了"
      )
    ));
  }
?>